﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SystemCenterSoa.DtoModel.Common;
using SystemCenterSoa.DtoModel.SystemManager;
using SystemCenterSoa.IRepository.SystemManager;
using SystemCenterSoa.PoModel.SystemManager;

namespace SystemCenterSoa.Service.SystemManager
{
    //RoleService
    public class RoleService
    {
        private IRoleRepository _IRoleRepository;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="iModuleDbDal">注入的dal</param>

        public RoleService(IRoleRepository IRoleRepository)
        {
            _IRoleRepository = IRoleRepository;
        }
        public RoleDto GetRoleDtoById(int roleId)
        {
            return _IRoleRepository.GetRoleDtoById(roleId);
        }
        public PagerResult<RolePo> SearchPage(SearchModel searchModel)
        {
            return _IRoleRepository.SearchPage(searchModel);
        }

        /// <summary>
        /// 角色添加
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        public int RolePoAdd(RoleDto view)
        {
            //添加当前日期
            view.creator_date = DateTime.Now;
            //添加人物名称
            view.creator_name = "zzz";
            return _IRoleRepository.RolePoAdd(view);
        }

        public bool RoleUpdate(RoleDto view)
        {
            view.modifi_date = DateTime.Now;
            view.modifi_name = "lzh";
            return _IRoleRepository.RoleUpdate(view);
        }

        //获取对应用户下面的角色获取，用中间表，进行联查获取
        //查询指定用户名下面的角色
        public List<RolePo> GetRolePosByUserName(string userName)
        {
            return _IRoleRepository.GetRolePosByUserName(userName);
        }
    }
}
